home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH1 / SRC / PAINTPIC.FRM < prev    next >
Text File  |  1995-12-13  |  6KB  |  193 lines

  1. VERSION 4.00
  2. Begin VB.Form PaintPicForm 
  3.    Caption         =   "PaintPicture"
  4.    ClientHeight    =   3960
  5.    ClientLeft      =   2085
  6.    ClientTop       =   1485
  7.    ClientWidth     =   5730
  8.    Height          =   4650
  9.    Left            =   2025
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3960
  12.    ScaleWidth      =   5730
  13.    Top             =   855
  14.    Width           =   5850
  15.    Begin VB.PictureBox Base 
  16.       AutoRedraw      =   -1  'True
  17.       AutoSize        =   -1  'True
  18.       Height          =   1020
  19.       Left            =   120
  20.       Picture         =   "PAINTPIC.frx":0000
  21.       ScaleHeight     =   64
  22.       ScaleMode       =   3  'Pixel
  23.       ScaleWidth      =   64
  24.       TabIndex        =   5
  25.       Top             =   1920
  26.       Width           =   1020
  27.    End
  28.    Begin VB.ListBox OpcodeList 
  29.       Height          =   3765
  30.       Left            =   1200
  31.       TabIndex        =   4
  32.       Top             =   120
  33.       Width           =   2295
  34.    End
  35.    Begin VB.PictureBox Destination 
  36.       AutoRedraw      =   -1  'True
  37.       AutoSize        =   -1  'True
  38.       Height          =   2040
  39.       Index           =   2
  40.       Left            =   3600
  41.       ScaleHeight     =   132
  42.       ScaleMode       =   3  'Pixel
  43.       ScaleWidth      =   132
  44.       TabIndex        =   3
  45.       Top             =   1800
  46.       Width           =   2040
  47.    End
  48.    Begin VB.PictureBox Destination 
  49.       AutoRedraw      =   -1  'True
  50.       AutoSize        =   -1  'True
  51.       Height          =   510
  52.       Index           =   0
  53.       Left            =   3600
  54.       ScaleHeight     =   30
  55.       ScaleMode       =   3  'Pixel
  56.       ScaleWidth      =   30
  57.       TabIndex        =   2
  58.       Top             =   120
  59.       Width           =   510
  60.    End
  61.    Begin VB.PictureBox Destination 
  62.       AutoRedraw      =   -1  'True
  63.       AutoSize        =   -1  'True
  64.       Height          =   1020
  65.       Index           =   1
  66.       Left            =   3600
  67.       ScaleHeight     =   64
  68.       ScaleMode       =   3  'Pixel
  69.       ScaleWidth      =   64
  70.       TabIndex        =   1
  71.       Top             =   720
  72.       Width           =   1020
  73.    End
  74.    Begin VB.PictureBox Source 
  75.       AutoRedraw      =   -1  'True
  76.       AutoSize        =   -1  'True
  77.       Height          =   1020
  78.       Left            =   120
  79.       Picture         =   "PAINTPIC.frx":0882
  80.       ScaleHeight     =   64
  81.       ScaleMode       =   3  'Pixel
  82.       ScaleWidth      =   64
  83.       TabIndex        =   0
  84.       Top             =   360
  85.       Width           =   1020
  86.    End
  87.    Begin VB.Label Label1 
  88.       Alignment       =   2  'Center
  89.       Caption         =   "Destination"
  90.       Height          =   255
  91.       Index           =   1
  92.       Left            =   120
  93.       TabIndex        =   7
  94.       Top             =   1680
  95.       Width           =   975
  96.    End
  97.    Begin VB.Label Label1 
  98.       Alignment       =   2  'Center
  99.       Caption         =   "Source"
  100.       Height          =   255
  101.       Index           =   0
  102.       Left            =   120
  103.       TabIndex        =   6
  104.       Top             =   120
  105.       Width           =   975
  106.    End
  107.    Begin VB.Menu mnuFile 
  108.       Caption         =   "&File"
  109.       Begin VB.Menu mnuFileExit 
  110.          Caption         =   "E&xit"
  111.       End
  112.    End
  113. End
  114. Attribute VB_Name = "PaintPicForm"
  115. Attribute VB_Creatable = False
  116. Attribute VB_Exposed = False
  117. Option Explicit
  118.  
  119. ' ***********************************************
  120. ' Add an opcode's name and value to the list of
  121. ' choices.
  122. ' ***********************************************
  123. Sub AddOpcode(name As String, value As Long)
  124.     OpcodeList.AddItem name
  125.     OpcodeList.ItemData(OpcodeList.NewIndex) = value
  126. End Sub
  127.  
  128.  
  129.  
  130.  
  131. Private Sub Form_Load()
  132. Dim copy_index As Integer
  133.  
  134.     ' Load the opcode choices.
  135.     AddOpcode "vbBlackness", vbBlackness
  136.     AddOpcode "vbDstInvert", vbDstInvert
  137.     AddOpcode "vbMergeCopy", vbMergeCopy
  138.     AddOpcode "vbMergePaint", vbMergePaint
  139.     AddOpcode "vbNotSrcCopy", vbNotSrcCopy
  140.     AddOpcode "vbSrcErase", vbSrcErase
  141.     AddOpcode "vbPatCopy", vbPatCopy
  142.     AddOpcode "vbPatInvert", vbPatInvert
  143.     AddOpcode "vbPatPaint", vbPatPaint
  144.     AddOpcode "vbSrcAnd", vbSrcAnd
  145.     AddOpcode "vbSrcCopy", vbSrcCopy
  146.     copy_index = OpcodeList.NewIndex
  147.     AddOpcode "vbSrcErase", vbSrcErase
  148.     AddOpcode "vbSrcInvert", vbSrcInvert
  149.     AddOpcode "vbSrcPaint", vbSrcPaint
  150.     AddOpcode "vbWhiteness", vbWhiteness
  151.  
  152.     ' Start with vbSrcCopy.
  153.     OpcodeList.ListIndex = copy_index
  154. End Sub
  155.  
  156. Private Sub mnuFileExit_Click()
  157.     Unload Me
  158. End Sub
  159.  
  160. Private Sub OpcodeList_Click()
  161. Const MAX_DEST = 2
  162.  
  163. Dim i As Integer
  164. Dim X As Single
  165. Dim Y As Single
  166. Dim wid As Single
  167. Dim hgt As Single
  168. Dim opcode As Long
  169.  
  170.     X = Source.ScaleLeft
  171.     Y = Source.ScaleTop
  172.     wid = Source.ScaleWidth
  173.     hgt = Source.ScaleHeight
  174.     opcode = OpcodeList.ItemData(OpcodeList.ListIndex)
  175.     
  176.     For i = 0 To MAX_DEST
  177.         With Destination(i)
  178.             ' Copy Base to the destination.
  179.             .PaintPicture Base.Picture, _
  180.                 .ScaleLeft, .ScaleTop, _
  181.                 .ScaleWidth, .ScaleHeight, _
  182.                 X, Y, wid, hgt, vbSrcCopy
  183.  
  184.             ' Add Source using the chosen opcode.
  185.             .PaintPicture Source.Picture, _
  186.                 .ScaleLeft, .ScaleTop, _
  187.                 .ScaleWidth, .ScaleHeight, _
  188.                 X, Y, wid, hgt, opcode
  189.         End With
  190.     Next i
  191. End Sub
  192.  
  193.